import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/api/type.dart';
import 'package:flutter_app/utils/http.dart';
import 'package:flutter_app/utils/address.dart';

class UserApi {
  static login(BuildContext context, phone, password) async {
    Map requestParams = {
      "mobileNumber": phone,
      "password": password,
      "authorizationCode": "",
      "countryCode": "+91"
    };
    var res = await httpManager.netFetch(context, Address.signInUrl,
        json.encode(requestParams), null, new Options(method: "post"));
    return new DataResult(res.data, res.result);
  }

  static getUserInfo(BuildContext context) async {
    return await httpManager.netFetch(
        context, Address.userInfoUrl, null, null, new Options(method: "get"));
  }

  static getProducts(BuildContext context) async {
    return await httpManager.netFetch(context, Address.getProductsUrl, null,
        null, new Options(method: "get"));
  }
}
